
/**********************************************/
/**************** REPICATION DO-FILE *************/
/**********************************************/

log using "/Users/alex/Dropbox/Papers Essex/FPA Revision/Final Submission/Log_FPA_Replication_War_Performance_Survival_FMs.smcl",replace

/**********************************************/
/**************** REPICATION DO-FILE *************/
/**********************************************/

use "/Users/alex/Dropbox/Papers Essex/FPA Revision/Final Submission/War_Performance_Survival_FMs_Replication_Data.dta",clear


/*Data already stset*/
stdescribe


******************************************
************Figure 1**********************
******************************************
graph hbar (percent) ccode2,over(sex) ytitle("Gender") xsize(12) name(sex)
graph hbar (percent) ccode2,over(agegroup) ytitle("Age") xsize(12) name(age)
graph hbar (percent) ccode2,over(education2) ytitle("Education") xsize(12) name(educ)
graph hbar (percent) ccode2,over(milexp) ytitle("Military experience") xsize(12) name(mil, replace)
graph hbar (percent) ccode2,over(dipexp) ytitle("Diplomatic experience") xsize(12) name(dip, replace)
graph hbar (percent) ccode2,over(politics2) ytitle("Political experience") xsize(12) name(pol)
graph combine age educ sex mil dip pol,col(2)

******************************************
************Table 1***********************
******************************************
preserve
gsort -tenure_month
list foreignminister country_name2 datein_str dateout_str tenure_month in 1/10
restore

******************************************
******************Table 2*****************
******************************************
tab exit, miss

******************************************
******************Figure 2****************
******************************************

*REPLICATION NOTE: The order of the countries produced by the code below*
*for the top-left graph (Mean Hostility Level) of Figure 2 is slightly*
*different than the order presented in the manuscript. The information*
*is identical but the order of countries is varies slightly.*
 
graph hbar (mean) maxhostlev, over(ccode2) legend(size(small)) ytitle("Mean Hostility Level") name(context1, replace)
graph hbar, over(win) legend(size(small)) ytitle("Foreign Ministers with MID Victory") name(context2, replace)
graph hbar, over(lose) legend(size(small)) ytitle("Foreign Ministers with MID Loss") name(context3, replace)
graph hbar, over(compromise) legend(size(small)) ytitle("Foreign Ministers with MID Compromise") name(context4, replace)
graph combine context1 context2 context3 context4, title("Situational Conflict Variables: Percentages")


******************************************
******************Table 3*****************
******************************************

******************Model 1******************
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2, shared(ccode)

******************Model 2******************
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 if anyconflict==1, shared(ccode)

******************Model 3******************
stcox polity2 maxhostlev anyconflict win lose compromise Any_MID_End, shared(ccode)

******************Model 4******************
stcox polity2 maxhostlev win lose compromise Any_MID_End if anyconflict==1, shared(ccode)

******************Model 5******************
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 maxhostlev anyconflict win lose compromise Any_MID_End, shared(ccode)

******************Model 6******************
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 maxhostlev win lose compromise Any_MID_End if anyconflict==1, shared(ccode)


******************************************
******************Table 4*****************
******************************************

******************Model 7******************
stcox previous_term politics2 vdem_politics2 dipexp vdem_dipexp milexp female agein hog education2 polity2 maxhostlev vdem_maxhostlev anyconflict win vdem_win lose vdem_lose compromise vdem_comp Any_MID_End, shared(ccode) 


******************************************
******************Appendix 1**************
******************************************

******************************************
******************Table A1****************
******************************************

*REPLICATION NOTE: The code below produces both estimation results with 'streg'*
*and a RTF of Table A1. The 'streg' code produces coefficients for *
*six Weibull models, and the 'eststo' and 'esttab' code produces their*
*exponentiated versions presented in Table A1. Unlike the other replication*
*code presented in this do-file, we choose to present code for coefficients and*
*code for Table A1 because Stata 15 does not produce exponentiated*
*coefficients for this type of specification with the modelling of an ancilliary*
*parameter (Stata 15 Manual p. 293). Therefore, readers interested in*
*replicating the estimates precisely as presented in Table A1, should install*
*the third-party ado-files for 'eststo' and 'esttab' and run the code below.*
*Readers interested simply on the coefficients do not need to run the *
*third-party ado-files and may focus only on the 'streg' code.*
*Substantive interpretation of results is equivalent across versions.*

******************Model 1******************
streg previous_term politics2 dipexp milexp female agein hog education2 polity2, d(w) anc(polity2) hr
eststo m1eh
******************Model 2******************
streg previous_term politics2 dipexp milexp female agein hog education2 polity2 if anyconflict==1, d(w) anc(polity2)
eststo m2eh
******************Model 3******************
streg polity2 maxhostlev anyconflict win lose compromise Any_MID_End, d(w) anc(polity2)
eststo m3eh
******************Model 4******************
streg polity2 maxhostlev win lose compromise Any_MID_End if anyconflict==1, d(w) anc(polity2)
eststo m4eh
******************Model 5******************
streg previous_term politics2 dipexp milexp female agein hog education2 polity2 maxhostlev anyconflict win lose compromise Any_MID_End, d(w) anc(polity2)
eststo m5eh
******************Model 6******************
streg previous_term politics2 dipexp milexp female agein hog education2 polity2 maxhostlev win lose compromise Any_MID_End if anyconflict==1, d(w) anc(polity2)
eststo m6eh

******************Table A1******************
esttab m1eh m2eh m3eh m4eh m5eh m6eh using TableA1.rtf, se parentheses nogaps obslast label mtitle("Model 1" "Model 2" "Model 3" "Model 4" "Model 5" "Model 6") star(* 0.1 ** 0.05 *** 0.01) r2 eform constant replace

******************************************
******************Appendix 2**************
******************************************

******************Model 1******************
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2, shared(ccode)
estat phtest, detail
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

******************Model 2******************
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 if anyconflict==1, shared(ccode)
estat phtest, detail
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

******************Model 3******************
stcox polity2 maxhostlev anyconflict win lose compromise Any_MID_End, shared(ccode)
estat phtest, detail
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

******************Model 4******************
stcox polity2 maxhostlev win lose compromise Any_MID_End if anyconflict==1, shared(ccode)
estat phtest, detail
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

******************Model 5******************
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 maxhostlev anyconflict win lose compromise Any_MID_End, shared(ccode)
estat phtest, detail
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

******************Model 6******************
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 maxhostlev win lose compromise Any_MID_End if anyconflict==1, shared(ccode)
estat phtest, detail
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

******************************************
******************Table A2****************
******************************************

******************Fix Model 3******************
stcox polity2 maxhostlev anyconflict win lose compromise Any_MID_End, shared(ccode)
estat phtest, detail
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank
*Polity2 is not proportional*
sum tenure_month
gen ln_tenure_month=ln(tenure_month+1)
gen lntime_polity2=ln_tenure_month*polity2
stcox polity2 lntime_polity2 maxhostlev anyconflict win lose compromise Any_MID_End, shared(ccode)


******************Fix Model 5******************
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 maxhostlev anyconflict win lose compromise Any_MID_End, shared(ccode)
estat phtest, detail
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank
*Polity2 is strongly not proportional. Polity2 has been fixed above*
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 lntime_polity2 maxhostlev anyconflict win lose compromise Any_MID_End, shared(ccode)


******************************************
******************Appendix 4**************
******************************************

******************************************
******************Table A3****************
******************************************

*************Forced. Model 5 in Table 3****
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 maxhostlev anyconflict win lose compromise Any_MID_End, shared(ccode)
stset,clear

******************Retirement***************
stset tenure_month, failure(retire==1)
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 maxhostlev anyconflict win lose compromise Any_MID_End, shared(ccode)
stset,clear

******************Violent******************
stset tenure_month, failure(violent==1)
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 maxhostlev anyconflict win lose compromise Any_MID_End, shared(ccode)
stset,clear

******************End Gov******************
stset tenure_month, failure(endgov==1)
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 maxhostlev anyconflict win lose compromise Any_MID_End, shared(ccode)
stset,clear


******************************************
******************Appendix 5**************
******************************************

******************************************
******************Table A4****************
******************************************

******************Ext. Model 5************
stset tenure_month, failure(forced_resign==1)
stcox previous_term politics2 dipexp milexp female agein hog education2 polity2 maxhostlev anyconflict win lose compromise Any_MID_End log_cgdppc, shared(ccode)
estat phtest, detail
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

log close






